Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecate RemoveOrgUser in favor of RemoveOrgUsers #10951

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tianrunhe
Copy link
Contributor

@tianrunhe tianrunhe commented Mar 4, 2025

Description

Deprecate RemoveOrgUser in favor of RemoveOrgUsers

Final checklist

  • I checked the code review guidelines
  • I have added Metrics Representative as reviewer(s) if my PR invovles metrics/data/analytics related changes
  • I have performed a self-review of my code, the same way I'd do it for any other team member
  • I have tested all cases I listed in the testing scenarios and I haven't found any issues or regressions
  • Whenever I took a non-obvious choice I added a comment explaining why I did it this way
  • I added the label Skip Maintainer Review Indicating the PR only requires reviewer review and can be merged right after it's approved if the PR introduces only minor changes, does not contain any architectural changes or does not introduce any new patterns and I think one review is sufficient'
  • PR title is human readable and could be used in changelog

@github-actions github-actions bot added the size/l label Mar 4, 2025
@tianrunhe
Copy link
Contributor Author

@Dschoordsch I've found a really confusing issue. The symptom is that with my changes in this PR, resolving of an User type in OrganizationUser field would fail, even though all the data are there.

For example, this resolves fine and returns a proper userId:

{
  viewer {
    id
    organization(orgId: "xxxx") {
      organizationUsers {
        edges {
          node {
            userId
          }
        }
      }
    }
  }
}

However, if you try to resolve a User object:

{
  viewer {
    id
    organization(orgId: "xxxx") {
      organizationUsers {
        edges {
          node {
            user {
              preferredName
            }
          }
        }
      }
    }
  }
}

Returns:

{
  "errors": [
    {
      "message": "Cannot return null for non-nullable field OrganizationUser.user.",
      "locations": [
        {
          "line": 8,
          "column": 13
        }
      ],
      "path": [
        "viewer",
        "organization",
        "organizationUsers",
        "edges",
        0,
        "node",
        "user"
      ]
    }
  ],
  "data": {
    "viewer": {
      "id": "google-oauth2|xxxx",
      "organization": null
    }
  }
}

More interestingly, I've nailed down the issue to the removal of removeOrgUser: if I added the mutation back to packages/server/graphql/rootMutation.ts (together with the type definitions: packages/server/graphql/mutations/removeOrgUser.ts, packages/server/graphql/public/typeDefs/RemoveOrgUserPayload.graphql and packages/server/graphql/types/RemoveOrgUserPayload.ts then this issue does not exist anymore???

I suspect there's something to do with how the GraphQL schema is generated/updated. I remember you had some work around this area. Do you have some insights here? Thank you soooo much!

@tianrunhe tianrunhe requested a review from Dschoordsch March 5, 2025 00:41
@tianrunhe tianrunhe marked this pull request as ready for review March 5, 2025 00:41
@Dschoordsch
Copy link
Contributor

@tianrunhe Without looking into it in detail, I suspect we're not registering a necessary type anymore. What happens is that the old graphql resolvers (the ones not in the private/public subdirectories) are not imported automatically. So we probably indirectly imported a necessary resolver (I guess the one for User) through rootMutation and removeOrgUser. We now need to manually add it to rootTypes.

@tianrunhe
Copy link
Contributor Author

@Dschoordsch Thanks for that! I manually added OrganizationUser type in rootTypes.ts and it worked! Now this is ready for review, thx again!

Copy link
Contributor

@Dschoordsch Dschoordsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Does not work for leaving an org: "rror: Cannot remove yourself"
image
  • Removing another user from that view does not update the list of org members

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants